//
//  LSZBigDataViewController.m
//  PartyClassCloud
//
//  Created by 梁素珍 on 2018/9/2.
//  Copyright © 2018年 九酷. All rights reserved.
//

#import "LSZBigDataViewController.h"
#import "TNAxleView.h"

@interface LSZBigDataViewController ()
@property(nonatomic,strong) UIView * viewTop;
@property(nonatomic,strong) UIView * viewLow;
@property(nonatomic,strong) UILabel * labelNum;
@property(nonatomic,strong) UILabel * labelNumBranch;
@property(nonatomic,strong) NSArray * arrayData;
@property(nonatomic,strong) UILabel * labelType;
@end

@implementation LSZBigDataViewController
-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [LSZRequestData initWithTheNumberParty:^(BOOL isOk, NSString * string, NSString * str)
    {
        if (isOk == YES) {
            self.labelNum.text = str;
        }
    }];
    [LSZRequestData initWithThenumberBranch:^(BOOL isOK, NSString * string, NSString * str)
    {
        if (isOK == YES) {
            self.labelNumBranch.text = str;
        }
    }];
    [LSZRequestData initWithTheLearningSituation:^(BOOL isOK, NSString * str, NSString * mutArrayData) {
        if (isOK == YES) {
            NSString * string = [[NSString alloc]initWithFormat:@"%@",mutArrayData];
            NSString *stringWithoutQuotation = [mutArrayData stringByReplacingOccurrencesOfString:@"[" withString:@""];
            NSString *stringWithoutQuotationTwo = [stringWithoutQuotation stringByReplacingOccurrencesOfString:@"]" withString:@""];
            self.arrayData = [stringWithoutQuotationTwo componentsSeparatedByString:@","]; //字符串按照【分隔成数组
            [self addLearningUI];
        }else{
            if ([str isEqualToString:@"重复登录"]) {
                [LSZPublicClassDataToll RepeatLoginInterfaceJump:self.view fromVC:@"LSZBigDataViewController"];
                self.viewTop.hidden = YES;
                self.labelType.hidden = YES;
            }else{
                [LSZPublicClassDataToll initWithAlertKuangView:self.view string:str];
            }
        }
    }];
}
-(void)goToLogin
{
    [LSZPublicClassDataToll goToLogin];
}
-(void)addNotificationCenter
{
    NSString * strDelete = [NSString stringWithFormat:@"%@Login",@"LSZBigDataViewController"];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(goToLogin) name:strDelete object:nil];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    [self addNotificationCenter];
    self.arrayData = [[NSArray alloc]init];;
    self.navigationItem.title = @"党建大数据";
    [self basicLayout];
}
-(void)basicLayout
{
    self.labelType = [[UILabel alloc]init];
    self.labelType.frame = CGRectMake(10, NAVIGATION_BAR_HEIGHT+10, ScreenWidth-20, 25);
    self.labelType.textColor = titleColorLSZ;
    self.labelType.font = FONT_(15);
    self.labelType.text = @"支部情况";
    [self.view addSubview:self.labelType];
    
    self.viewTop = [[UILabel alloc]init];
    self.viewTop.frame = CGRectMake(0, CGRectGetMaxY(self.labelType.frame)+10, ScreenWidth, 150);
    self.viewTop.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:self.viewTop];
    
    UIImageView * imageViewNum = [[UIImageView alloc]init];
    imageViewNum.frame = CGRectMake((self.viewTop.frame.size.width/2-40)/2, 15, 40, 40);
    imageViewNum.image = [UIImage imageNamed:@"数据_人数"];
    [self.viewTop addSubview:imageViewNum];
    
    self.labelNum = [[UILabel alloc]init];
    self.labelNum.frame = CGRectMake(0, CGRectGetMaxY(imageViewNum.frame)+15, self.viewTop.frame.size.width/2, 35);
    self.labelNum.textColor = titleColorLSZ;
    self.labelNum.font = FONT_(22);
    self.labelNum.textAlignment = NSTextAlignmentCenter;
    [self.viewTop addSubview:self.labelNum];
    
    UILabel * labelNumTitle = [[UILabel alloc]init];
    labelNumTitle.frame = CGRectMake(0, CGRectGetMaxY(self.labelNum.frame)+5,self.labelNum.frame.size.width , 25);
    labelNumTitle.text = @"党建人数";
    labelNumTitle.font = FONT_(15);
    labelNumTitle.textColor = lightColor;
    labelNumTitle.textAlignment = NSTextAlignmentCenter;
    [self.viewTop addSubview:labelNumTitle];
    
    UIImageView * imageViewNumBranch = [[UIImageView alloc]init];
    imageViewNumBranch.frame = CGRectMake(self.viewTop.frame.size.width/2+(self.viewTop.frame.size.width/2-40)/2, 15, 40, 40);
    imageViewNumBranch.image = [UIImage imageNamed:@"党建_图"];
    [self.viewTop addSubview:imageViewNumBranch];
    
    self.labelNumBranch = [[UILabel alloc]init];
    self.labelNumBranch.frame = CGRectMake(self.viewTop.frame.size.width/2, CGRectGetMaxY(imageViewNumBranch.frame)+15, self.viewTop.frame.size.width/2, 35);
    self.labelNumBranch.textColor = titleColorLSZ;
    self.labelNumBranch.font = FONT_(22);
    self.labelNumBranch.textAlignment = NSTextAlignmentCenter;
    [self.viewTop addSubview:self.labelNumBranch];
    
    UILabel * labelNumTitleBranch = [[UILabel alloc]init];
    labelNumTitleBranch.frame = CGRectMake(self.viewTop.frame.size.width/2, CGRectGetMaxY(self.labelNumBranch.frame)+5,self.labelNum.frame.size.width , 25);
    labelNumTitleBranch.text = @"党支部数";
    labelNumTitleBranch.font = FONT_(15);
    labelNumTitleBranch.textColor = lightColor;
    labelNumTitleBranch.textAlignment = NSTextAlignmentCenter;
    [self.viewTop addSubview:labelNumTitleBranch];
}
-(void)addLearningUI
{
    UIView * view = [[UIView alloc]init];
    view.frame =CGRectMake((self.viewTop.frame.size.width-1)/2, 15, 1, self.viewTop.frame.size.height-30);
    view.backgroundColor  = dividerColor;
    [self.viewTop addSubview:view];
    
    UILabel * labelLearningType = [[UILabel alloc]init];
    labelLearningType.text = @"学习情况";
    labelLearningType.textColor = titleColorLSZ;
    labelLearningType.frame = CGRectMake(10, CGRectGetMaxY(self.viewTop.frame)+10, ScreenWidth-20, 20);
    [self.view addSubview:labelLearningType];
    
    UIView * viewLow = [[UIView alloc]init];
    viewLow.frame = CGRectMake(0, CGRectGetMaxY(labelLearningType.frame)+10, ScreenWidth, 200);
    viewLow.backgroundColor = [UIColor whiteColor];
    [self.view addSubview:viewLow];
    
    TNAxleView *axleView = [[TNAxleView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, viewLow.frame.size.height) withArray:self.arrayData];
    axleView.userInteractionEnabled = NO;
    [viewLow addSubview:axleView];
}
@end
